/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gmao.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Amine
 */
@Entity
@Table(name = "pieces")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Pieces.findAll", query = "SELECT p FROM Pieces p"),
    @NamedQuery(name = "Pieces.findByNom", query = "SELECT p FROM Pieces p WHERE p.nom = :nom"),
    @NamedQuery(name = "Pieces.findByDateMiseEnMarche", query = "SELECT p FROM Pieces p WHERE p.dateMiseEnMarche = :dateMiseEnMarche"),
    @NamedQuery(name = "Pieces.findByDureeDeVie", query = "SELECT p FROM Pieces p WHERE p.dureeDeVie = :dureeDeVie"),
    @NamedQuery(name = "Pieces.findByCout", query = "SELECT p FROM Pieces p WHERE p.cout = :cout"),
    @NamedQuery(name = "Pieces.findByDesignation", query = "SELECT p FROM Pieces p WHERE p.designation = :designation"),
    @NamedQuery(name = "Pieces.findByIdentifiantPiece", query = "SELECT p FROM Pieces p WHERE p.identifiantPiece = :identifiantPiece"),
    @NamedQuery(name = "Pieces.findByReference", query = "SELECT p FROM Pieces p WHERE p.reference = :reference")})
public class Pieces implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "nom")
    private String nom;
    @Size(max = 1)
    @Column(name = "date_mise_en_marche")
    private String dateMiseEnMarche;
    @Column(name = "duree_de_vie")
    private Integer dureeDeVie;
    @Column(name = "cout")
    private Integer cout;
    @Size(max = 1)
    @Column(name = "designation")
    private String designation;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "identifiant_piece")
    private String identifiantPiece;
    @Size(max = 1)
    @Column(name = "reference")
    private String reference;
    @JoinColumn(name = "id_machine", referencedColumnName = "id_machine")
    @ManyToOne
    private Machine idMachine;
    @JoinColumn(name = "ident_intervention", referencedColumnName = "ident_intervention")
    @ManyToOne
    private Intervention identIntervention;

    public Pieces() {
    }

    public Pieces(String identifiantPiece) {
        this.identifiantPiece = identifiantPiece;
    }

    public Pieces(String identifiantPiece, String nom) {
        this.identifiantPiece = identifiantPiece;
        this.nom = nom;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getDateMiseEnMarche() {
        return dateMiseEnMarche;
    }

    public void setDateMiseEnMarche(String dateMiseEnMarche) {
        this.dateMiseEnMarche = dateMiseEnMarche;
    }

    public Integer getDureeDeVie() {
        return dureeDeVie;
    }

    public void setDureeDeVie(Integer dureeDeVie) {
        this.dureeDeVie = dureeDeVie;
    }

    public Integer getCout() {
        return cout;
    }

    public void setCout(Integer cout) {
        this.cout = cout;
    }

    public String getDesignation() {
        return designation;
    }

    public void setDesignation(String designation) {
        this.designation = designation;
    }

    public String getIdentifiantPiece() {
        return identifiantPiece;
    }

    public void setIdentifiantPiece(String identifiantPiece) {
        this.identifiantPiece = identifiantPiece;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public Machine getIdMachine() {
        return idMachine;
    }

    public void setIdMachine(Machine idMachine) {
        this.idMachine = idMachine;
    }

    public Intervention getIdentIntervention() {
        return identIntervention;
    }

    public void setIdentIntervention(Intervention identIntervention) {
        this.identIntervention = identIntervention;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (identifiantPiece != null ? identifiantPiece.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pieces)) {
            return false;
        }
        Pieces other = (Pieces) object;
        if ((this.identifiantPiece == null && other.identifiantPiece != null) || (this.identifiantPiece != null && !this.identifiantPiece.equals(other.identifiantPiece))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gmao.entities.Pieces[ identifiantPiece=" + identifiantPiece + " ]";
    }
    
}
